<div class="row">
	<div class="col-sm-12" style="width: 99%;">
		<div class="nest" id="treeClose">
			<div class="title-alt">
				<h6>Địa điểm</h6>
			</div>

			<div class="body-nest" id="tree" style="min-height: 490px">
    				<div class="row">
                        <div class="col-sm-5">
                        <div class="nest" id="validationClose">
                            <div class="title-alt" style="margin: 0px auto 0;">
                                <h6><?php echo $type == 'edit' ? 'Sửa' : 'Thêm'?> địa điểm</h6>
                                <div class="titleToggle">
                                    <a class="nav-toggle-alt" href="#validation">
                                        <span class="entypo-up-open"></span>
                                    </a>
                                </div>
                            </div>
                            <div class="body-nest" id="validation">
                                <div class="form_center" style="width: 90%;">
                                    <?php if(validation_errors() || @$error || @$zero):?>
                                    
                                    <div class="alert alert-danger">
                                        <button data-dismiss="alert" class="close" type="button">×</button>
                                        <span class="entypo-attention"></span>
                                        <strong>Oh lỗi!</strong>&nbsp;&nbsp;<?php echo validation_errors(); ?>
                                        <?php if(@$error):?>
                                        <br />
                                        <?php echo $error?>
                                        <?php endif;?>
                                        <?php if(@$zero):?>
                                        <br />
                                        
                                        <script>
                                        jAlert('Vui lòng chọn đầy đủ địa chỉ.', 'Thông báo', function()
                                        {
                                            window.location = '<?php echo site_url().'/passwd'?>'; 
                                        });
                                        </script>
                                        <?php endif;?>
                                        
                                    </div>
                                    <?php endif;?>
                                    <?php if(@$status):?>
                                        <script>
                                        jAlert('<?php echo $status;?>', 'Thông báo', function()
                                        {
                                            window.location = '<?php echo site_url().'/place'?>'; 
                                        });
                                        </script>
                                    <?php endif;?>
                                    <?php $att = array('id' => 'contact-form', 'class' => 'form-horizontal'); echo form_open('', $att);?>
                                        <input type="hidden" name="id" value="<?php echo $id?>" />
                                        <input type="hidden" name="type" value="<?php echo $type?>" />
                                        <fieldset>
                                            <div class="control-group">
                                                <label class="control-label" for="name">Chọn tỉnh <small style="color:  red;">(*)</small></label>
                                                <div class="controls">
                                                    <?php echo $fview->selectOption($province, @$dataedit->id_province ? @$dataedit->id_province : $this->input->post('province'), 'form-control', 'province', 'province');?>
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label class="control-label" for="email">Chọn quận huyện <small style="color:  red;">(*)</small></label>
                                                <div class="controls" id="district_select">
                                                    <?php echo $fview->selectOption(@$district ? @$district : array('Vui lòng chọn tỉnh thành phố'), @$dataedit->id_district ? @$dataedit->id_district : $this->input->post('district'), 'form-control', 'district', 'district');?>
                                                </div>
                                            </div>
                                            <div class="control-group" id="box-map" style="display: none;">
                                                <div align="center" id="map" style="width: 350px; height: 200px; position: relative; top: 2%; right: 5px; z-index: 999999; box-shadow: rgb(85, 85, 85) 0px 2px 6px; overflow: hidden; transform: translateZ(0px) translateZ(0px) translateZ(0px) translateZ(0px) translateZ(0px) translateZ(0px); background: rgb(255, 255, 255);"><br/></div>
                                                <div class="close-map show_msg" >
                                                    Đang tải ...
                                                </div>
                                                <div class="close-map" >
                                                    [ Tắt ]
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label class="control-label" for="subject">Tên cửa hàng <small style="color:  red;">(*)</small></label>
                                                <div class="controls">
                                                    <input type="text" class="form-control name" value="<?php echo @$dataedit->name ? @$dataedit->name : $this->input->post('name')?>" name="name" id="name" />
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label class="control-label" for="subject">Địa chỉ <small style="color:  red;">(*)</small></label>
                                                <div class="controls">
                                                    <input type="text" class="form-control address" value="<?php echo @$dataedit->address ? @$dataedit->address : $this->input->post('address')?>" name="address" id="address" />
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label class="control-label" for="subject">Lat</label>
                                                <div class="controls">
                                                    <input type="text" class="form-control" value="<?php echo @$dataedit->lat ? @$dataedit->lat : $this->input->post('lat')?>" name="lat" id="lat" />
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label class="control-label" for="subject">Long</label>
                                                <div class="controls">
                                                    <input type="text" class="form-control" value="<?php echo @$dataedit->long ? @$dataedit->long : $this->input->post('long')?>" name="long" id="lng" />
                                                </div>
                                            </div>
                                            <div class="form-actions" style="margin:20px 0 0 0;float: right">
                                                <button type="submit" class="btn btn-primary">Đồng ý</button>
                                            </div>
                                        </fieldset>
                                    </form>

                                </div>
                            </div>



                        </div>
                    </div>
    					<div class="col-sm-7">
    						<div class="nest" id="tableStaticClose">
                            <div class="title-alt" style="margin: 0px auto 0;">
                                <h6>Danh sách địa điểm</h6>
                                <div class="titleToggle">
                                    <a class="nav-toggle-alt" href="#tableStatic">
                                        <span class="entypo-up-open"></span>
                                    </a>
                                </div>

                            </div>

                            <div class="body-nest" id="tableStatic">

                                <section id="flip-scroll">

                                    <table class="table table-bordered table-striped cf">
                                        <thead class="cf">
                                            <tr>
                                                <th>STT</th>
                                                <th>Tên địa điểm</th>
                                                <th>Quận/Huyện</th>
                                                <th>Tỉnh/Thành phố</th>
                                                <th>Tác vụ</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php if($data):?>
                                            <?php foreach($data AS $el=>$le):?>
                                            <tr <?php echo ($le->id == $id) ? 'class="show-edit"' : '';?>>
                                                <td><?php echo ($el + 1)?></td>
                                                <td><?php echo $le->address?></td>
                                                <td><?php echo $le->dname?></td>
                                                <td><?php echo $le->pname?></td>
                                                <td>
                                                <a href="<?php echo site_url().'place?type=edit&id='.$le->id?>">
                                                    Sửa
                                                </a>
                                                 | 
                                                <a href="<?php echo site_url().'place?type=delete&id='.$le->id?>">
                                                    Xóa
                                                </a>
                                                </td>
                                            </tr>
                                            <?php endforeach;?>
                                        <?php endif;?>
                                        
                                        </tbody>
                                        <tfoot>
                                            <tr>
                                                <td colspan="5" id="pagination"><?php echo $this->pagination->create_links();?></td>
                                            </tr>
                                        </tfoot>
                                    </table>
                                </section>

                            </div>

                        </div>

    					</div>
    				</div>
			</div>
		</div>
        
	</div>
    <style>
    #pagination{
        
    }
    #pagination a{
            padding: 3px 10px;
            margin: 10px 2px;
            border: 1px solid #CCC;
            background: #CCC;
            color: #FFF;
    }
    #pagination strong{
            padding: 3px 10px;
            margin: 10px 2px;
            border: 1px solid #CCC;
    }
    #box-map{
        float: right !important;width: 348px;margin: 15px;margin-right: 0px;
    }
    </style>
    <script>
        $(document).ready(function()
        {
            $("#province").on('change', function()
            {
               var id_province = $(this).val();
               $("#district_select").html('<input type="text" value="Plz, waitting..." class="form-control" name="">');
               $.ajax({
                    type: 'get',
                    url: '<?php echo site_url('get-district');?>',
                    data: ({id: id_province}),
                    success: function(_data)
                    {
                        $("#district_select").html(_data);
                    }
               });
            }); 
        })
        
        $(function()
        {
           $('.close-map').click(function()
           {
                $("#box-map").hide();
                checkpopup = 1;
           });
        });
    </script>
    <style>
    .close-map{
        width: 50px;position: absolute;top: 29%;z-index: 999999;background: #FFF;padding: 6px;cursor: pointer;color: red;
    }
    .show_msg{
        right: 37px;width: 94px;
    }
    </style>
</div>